package cn.com.zhuxulin.android.demos.bussiness;

import java.util.ArrayList;
import java.util.Iterator;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;

public class SendSMSMessage {
	private Context context = null;
	private SmsManager smsManager = null;
	private String textMsg = null;

	public SendSMSMessage(Context context) {
		this.context = context;
		smsManager = SmsManager.getDefault();
	}

	public void sendMsg(String telNum, String textMsg) {
		smsManager.sendTextMessage(telNum, null, textMsg, null, null);
	}

	public void sendMsg() {
		ArrayList<String> msgs = smsManager.divideMessage(textMsg);
		Iterator<String> allMsg = msgs.iterator();
		Intent sent = new Intent("");
		PendingIntent isSent = PendingIntent.getBroadcast(context, 0, sent, 0);
		Intent deliver = new Intent("");
		PendingIntent isDeliver = PendingIntent.getBroadcast(context, 0,
				deliver, 0);
		while (allMsg.hasNext()) {
			smsManager.sendTextMessage("", null, allMsg.next(), isSent,
					isDeliver);
		}
	}
}
